package uumoi

class Brand implements Comparable<Brand> {
	String name
	String description

	CompanyInformation companyInformation
	Image watermark

	@Override
	int compareTo(Brand o) {
		return name.compareTo(o.name)
	}

	static belongsTo = [account: Account]
	static hasMany = [regions: Region, tags: HashTag]
	SortedSet regions

	static constraints = {
		description nullable: true
		companyInformation nullable: true
		watermark nullable: true
	}

	static mapping = {
		tags fetch: 'join'
		//regions lazy: false
	}

	static canAccess(Long id, Account account) {
		return executeQuery("select b.id from Brand b where :id = b.id and :account = b.account", [id: id, account: account])
	}
}
